<template>
    <div>
        <el-button type="primary" @click="hanldeClick('insert')">新增配置</el-button>
        <el-table  :data="list" tooltip-effect="dark"  style="width: 100%" >
            <el-table-column prop="rank" label="排序" min-width="80"> </el-table-column>
            <el-table-column prop="name" label="物料检验项目名称" min-width="200"> </el-table-column>
            <el-table-column prop="type" label="配置类型" :formatter='formatterType'> </el-table-column>
            <el-table-column prop="reference" label="检验参考值"> </el-table-column>
            <el-table-column prop="unit" label="单位"> </el-table-column>
            <el-table-column prop="isEnable" label="是否启用" :formatter='formartIsEnable'> </el-table-column>
            <el-table-column prop="creatorName" label="创建人" min-width="80"></el-table-column>
            <el-table-column prop="createTime" label="创建时间" min-width="160"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" width="160">
                <template slot-scope="scope">
                    <el-button @click="hanldeClick('update',scope.row)" type="text" size="small">编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
export default {
    props:{
        list:Array
    },
    data(){
        return {
            processTypeConfig: [{
            type:'0',
            name:'指标'
            }, {
                type: '1',
                name: '判定'
            }, {
                type: '2',
                name: '单位指标'
            }, {
                type: '3',
                name: '图片上传'
            }]
        }
    },
    methods:{
         formartIsEnable(row, column, cellValue, index){
            return cellValue == 1 ? '启用' : (cellValue == 0 ? '未启用' : "");
        },
          formatterType(row, column, cellValue, index){
            let value;
            this.processTypeConfig.forEach(el=>{
                if(el.type===cellValue){
                 value=el.name;
                }
            })
            return value;
        },
        hanldeClick(type,row){
            let self = this;
            self.$emit('addUpdateCheck',{type,row})
        }
    }
}
</script>
<style scoped>

</style>


